
{include file="layout/css"}
{include file="layout/header"}
<div class="fly-panel fly-column">
    <div class="layui-container">
        <ul class="layui-clear">
            <li class="layui-hide-xs"><a href="{:url('forum',['type'=>'all'])}">首页</a></li>
            <li class=""><a href="{:url('forum',['type'=>'bug'])}">提交BUG/建议</a></li>
            <li class=""><a href="{:url('forum',['type'=>'update'])}">【更新公告】</a></li>
        </ul>
    </div>
</div>

<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="fly-panel detail-box" id="flyReply">
                <h1 class="forum-title">{$forum.title}</h1>
                <div class="fly-detail-info">
                    <span class="layui-badge forum-type">{$forum.type}</span>
                    <div class="fly-admin-box" data-id="123"></div>
                    <span class="fly-list-nums">
                        <a href="#comment"><i class="iconfont" title="回答">&#xe60c;</i> <span class="reply-count">0</span></a>
                        <i class="iconfont" title="人气">&#xe60b;</i> <span class="view-count">0</span>
                    </span>
                </div>
                <div class="detail-about">
                    <a class="fly-avatar" >
                        <img src="{$forum.user.head_pic}" alt="">
                    </a>
                    <div class="fly-detail-user">
                        <a class="fly-link">
                            <cite class="forum-author">{$forum.user.nickname}</cite>
                        </a>
                    </div>
                    <div class="detail-hits">
                        <span class="forum-time">{$forum.create_time}</span>
                    </div>
                </div>
                <div class="detail-body layui-text forum-content">
                    {$forum.content}
                </div>
            </div>

<!--            <div class="fly-panel detail-box" id="flyReply">-->
<!--                <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">-->
<!--                    <legend>回帖</legend>-->
<!--                </fieldset>-->

<!--                <ul class="jieda" id="jieda">-->
<!--                    &lt;!&ndash; 回复列表 &ndash;&gt;-->
<!--                </ul>-->
<!--                -->
<!--                &lt;!&ndash; 回复表单 &ndash;&gt;-->
<!--                <div class="layui-form layui-form-pane">-->
<!--                    <form action="" method="post" id="replyForm">-->
<!--                        <div class="layui-form-item layui-form-text">-->
<!--                            <a name="comment"></a>-->
<!--                            <div class="layui-input-block">-->
<!--                                <textarea id="reply-content" name="content" required lay-verify="required" placeholder="请输入回复内容" class="layui-textarea fly-editor" style="height: 150px;"></textarea>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                        <div class="layui-form-item">-->
<!--                            <input type="hidden" name="forum_id" id="forum_id" value="">-->
<!--                            <button class="layui-btn" lay-filter="replySubmit" lay-submit>提交回复</button>-->
<!--                        </div>-->
<!--                    </form>-->
<!--                </div>-->
<!--            </div>-->
        </div>
    </div>
</div>

<script>
    layui.use(['form', 'layer', 'facade', 'laytpl'], function(){
        var form = layui.form;
        var layer = layui.layer;
        var facade = layui.facade;
        var laytpl = layui.laytpl;
        var $ = layui.$;

        // 检查用户是否登录
        var user = localStorage.getItem("user");
        if(!user){
            $('#replyForm').html('<div class="fly-none">请先<a href="/login.html">登录</a>后才能回复</div>');
        }
        
        // 提交回复
        form.on('submit(replySubmit)', function(data){
            var field = data.field;
            
            if(!field.content){
                layer.msg('回复内容不能为空', {icon: 5});
                return false;
            }
            
            facade.ajax({
                route: "/forum/reply",
                data: field,
                successMsg: '回复成功'
            }).done(function(res){
                if(res.code === 0){
                    // 刷新页面
                    setTimeout(function(){
                        location.reload();
                    }, 1500);
                }
            });
            
            return false;
        });
    });
</script>

{include file="layout/footer"}
</body>
</html>